var appendToolsBtn;
var onBackRequest; //当点击返回按钮时触发，返回false阻止返回事件。
$(function(){
    var bodyContent = $("body");
    var toolContent = $("<div class='tool'></div>").appendTo(bodyContent);
    var content = $("<div class='inner-content'></div>").appendTo(toolContent);
    bodyContent.prepend("<div class='tool-background'></div>");
    appendToolsBtn = function(btnText,field){
        field=field||"";
        var btn = $("<button "+field+">"+btnText+"</button>").appendTo(content);
        if(content.children().length>1) {
            var last = content.children().eq(content.children().length-2);
            btn.offset({left:last.outerWidth()+last.offset().left+5});
        }
        return btn;
    }
    prevBtn = appendToolsBtn("返回");
    descBtn = appendToolsBtn("描述");
    prevBtn.click(function(){
        if(typeof onBackRequest === 'function'){
            if(onBackRequest() === false){
                return;
            }
        }
        history.back();
    });
    descBtn.click(function(){
        createDialog({title:'工具自述',content:getGetUrlParam(location.href).desc,type:'info'}).show();
    });
})

